﻿using Echo.Context.UltiProNet.Contexts;
using Echo.Core.TestAbstraction.WebUITest.MbUnit;
using Echo.Models.UltiProNet;
using Echo.Models.UltimateSoftware.WebUITest.MbUnit;
using MbUnit.Framework;

////*************************************************************************************************************************************
////Created by:Yesenia Sosa
////Date created:10/2/2012
////Modified by: 
////Date modified: 
////Reason: 
////ULTI-75062  Echo Conversion - Business Rules - GTL Non Edit Fields
////*************************************************************************************************************************************

namespace Echo.Automation.Compliance.BusinessRules
{
    [TestFixture]
    [Header("Config")]
    [Config(".NET")]
    [Author("Yesenia Sosa", "yesenia_sosa@ultimatesoftware.com")]
    [Category("Taxes")]
    [Category("Business Rules")]
    public class TestGTLNonEditFields : MbUnitAutomatedTest
    {
        UltiPro UltiPro;
        UltiProDatabaseContext Database;

        [FixtureSetUp]
        public void FixtureSetUp()
        {
            #region Given that UltiPro is launched and I am logged in as MerrillG
            UltiPro = Launch<UltiPro>();
            Database = Init<UltiProDatabaseContext>();
            Database.Company = ConfigDatabase("ULTIPRO_CALENDAR");
            UltiPro.Pages.Login.LoginAs("merrillg", "password", Config.LanguageCode);
            UltiPro.Pages.CompanySelector.ChooseCompanies("CALEN", "C0014");
            #endregion
        }

        [Test]
        public void VerifyRuleFieldIsNonEditable()
        {
            #region When I navigate to employee page via my team
            UltiPro.Menu.MyTeam.Click(x => x.MyEmployees);
            UltiPro.Pages.EeMain.EmployeeGrid.Find(x => x.LastName, FilterType.Is, "Trinblat");
            UltiPro.Pages.EeMain.EmployeeGrid.Row(grid => grid.Name, "Trinblat (Grinblat), Babe G.", grid => grid.Company, "Web Payroll Company").Click(x => x.Name);
            #endregion

            #region Then I view my deductions and select CHARITY
            UltiPro.Browser.SwitchToWindow("Terrill");
            UltiPro.Menu.MyTeam.SubMenu.Click(x => x.Pay);
            UltiPro.Menu.MyTeam.SubMenu.Pay.Click(x => x.Deductions);
            UltiPro.Pages.EeDedSummary.DeductionSummaryGrid.Row(grid => grid.Plan, "CHARITY").Click(x => x.Plan);
            #endregion

            #region Then I pick a change reason and navigate to the Calculations page
            UltiPro.Browser.SwitchToWindow("Add/Change Deduction");
            UltiPro.Pages.DeductionAddChangeStart.Set(x => x.ChangeReasonDropDown, "400"); // "Add deduction"
            UltiPro.Pages.DeductionAddChangeStart.ButtonBar.Click(x => x.Next);
            UltiPro.Pages.DeductionAddChangeDetails.ButtonBar.Click(x => x.Next);
            #endregion

            #region And Then I verify the calculation rule drop down is disabled.
            UltiPro.Pages.DeductionAddChangeCalculations.NotEnabled(x => x.EmployeeRuleDropDown);
            #endregion
        }

        [FixtureTearDown]
        public void FixtureTearDown()
        {
            UltiPro.Browser.Quit();
        }
    }
}
